<template>
  <el-select style="width:100%;" :size="styleSize" clearable filterable @change="changeData" v-model="model"
             placeholder="请选择">
    <el-option
        v-for="item in options"
        :key="item.dataCode"
        :label="item.dataCode"
        :value="item.dataValue">
    </el-option>
  </el-select>
</template>

<script setup>
import {onMounted, ref} from "vue";
import http from "@/utils/request";

const props = defineProps(['catalog', "size", "dataType"])
const model = defineModel()
const options = ref([]);
onMounted(async () => {

  let param = {};
  param.dictKey = props.catalog;
  let res = await http.form(`/dictItem/list`, param);
  if (res.code === 200) {
    if (props.dataType === 'number') {
      console.info("数字类型")
      options.value = res.data.map(item => {
        item.dataValue = parseInt(item.dataValue+"");
        return item;
      })
    } else {
      options.value = res.data;

    }

  }
})

</script>

<style scoped>

</style>
